package com.autumn.domain.repositories.plugins;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.ibatis.plugin.Interceptor;

import com.autumn.mybatis.mapper.MapperInfo;
import com.autumn.mybatis.mapper.MapperRegister;

/**
 * 
 * @author xinghua 2017年12月8日 下午3:44:40
 */
public abstract class AbstractAuditingPlugin implements Interceptor {

	private final static Map<String, MapperAuditingInfo> MSID_MAPPER_AUDITING_MAP = new ConcurrentHashMap<String, MapperAuditingInfo>();

	/**
	 * 获取审计 Mapper 审计信t息
	 * 
	 * @param msId
	 * @return
	 *
	 */
	public static MapperAuditingInfo getMapperAuditingInfo(String msId) {
		MapperAuditingInfo info = MSID_MAPPER_AUDITING_MAP.get(msId);
		if (info != null) {
			return info;
		}
		MapperInfo mapperInfo = MapperRegister.getMapperInfo(msId);
		if (mapperInfo != null) {
			info = new MapperAuditingInfo(mapperInfo);
			MSID_MAPPER_AUDITING_MAP.put(msId, info);
			return info;
		}
		return null;
	}

}
